package com.ruoyi.performancecomparisons.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.performancecomparisons.domain.Performancecomparisons;
import com.ruoyi.performancecomparisons.service.IPerformancecomparisonsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模板管理Controller
 * 就是划分条件啥的
 * @author yxy
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/performancecomparisons/performancecomparisons")
public class PerformancecomparisonsController extends BaseController
{
    @Autowired
    private IPerformancecomparisonsService performancecomparisonsService;

    /**
     * 查询模板管理列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(Performancecomparisons performancecomparisons)
    {
        startPage();
        List<Performancecomparisons> list = performancecomparisonsService.selectPerformancecomparisonsList(performancecomparisons);
        return getDataTable(list);
    }

    /**
     * 导出模板管理列表
     */
    @PreAuthorize("@ss.hasPermi('performancecomparisons:performancecomparisons:export')")
    @Log(title = "模板管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Performancecomparisons performancecomparisons)
    {
        List<Performancecomparisons> list = performancecomparisonsService.selectPerformancecomparisonsList(performancecomparisons);
        ExcelUtil<Performancecomparisons> util = new ExcelUtil<Performancecomparisons>(Performancecomparisons.class);
        util.exportExcel(response, list, "模板管理数据");
    }

    /**
     * 获取模板管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('performancecomparisons:performancecomparisons:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(performancecomparisonsService.selectPerformancecomparisonsById(id));
    }

    /**
     * 新增模板管理
     */
    @PreAuthorize("@ss.hasPermi('performancecomparisons:performancecomparisons:add')")
    @Log(title = "模板管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Performancecomparisons performancecomparisons)
    {
        return toAjax(performancecomparisonsService.insertPerformancecomparisons(performancecomparisons));
    }

    /**
     * 修改模板管理
     */
    @PreAuthorize("@ss.hasPermi('performancecomparisons:performancecomparisons:edit')")
    @Log(title = "模板管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Performancecomparisons performancecomparisons)
    {
        return toAjax(performancecomparisonsService.updatePerformancecomparisons(performancecomparisons));
    }

    /**
     * 删除模板管理
     */
    @PreAuthorize("@ss.hasPermi('performancecomparisons:performancecomparisons:remove')")
    @Log(title = "模板管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(performancecomparisonsService.deletePerformancecomparisonsByIds(ids));
    }
}
